/*
 * Project it.battlehorse.rcp.tools
 * Created on Nov 18, 2005
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * A copy of the LGPL is available also at
 * http://www.gnu.org/copyleft/lesser.html
 * 
 */ 
package it.battlehorse.rcp.tools;

import it.battlehorse.rcp.tools.commons.CommonsActivator;
import it.battlehorse.rcp.tools.commons.Severity;
import it.battlehorse.rcp.tools.log.LogActivator;
import it.battlehorse.rcp.tools.perspectives.ActorPerspective;

import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.ui.IWorkbenchPreferenceConstants;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.application.IWorkbenchConfigurer;
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
import org.eclipse.ui.application.WorkbenchAdvisor;
import org.eclipse.ui.application.WorkbenchWindowAdvisor;

/**
 * The workbench advisor
 * 
 * @author battlehorse
 * @since Nov 18, 2005
 */
public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor {

	@Override
    public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
        return new ApplicationWorkbenchWindowAdvisor(configurer);
    }

	@Override
	public String getInitialWindowPerspectiveId() {
		return ActorPerspective.ID_PERSPECTIVE;
	}
	
	@Override public void initialize(IWorkbenchConfigurer configurer) {
		super.initialize(configurer);
		configurer.setSaveAndRestore(true);
		
		PlatformUI.getPreferenceStore().setValue(IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS, false);
		PlatformUI.getPreferenceStore().setValue(IWorkbenchPreferenceConstants.DOCK_PERSPECTIVE_BAR, IWorkbenchPreferenceConstants.TOP_RIGHT);
		
		initImageRegistries();
	}
	
	/**
	 * Initializes the image registry used by the plugin
	 *
	 */
	private void initImageRegistries() {
		
		ImageRegistry registry = CommonsActivator.getDefault().getImageRegistry();
		
		// Init the image registry entries		
		for (Severity s : Severity.values()) {
			registry.put(s.getImageKey(), s.getImageDescriptor());
		}
		
		registry = LogActivator.getDefault().getImageRegistry();
		registry.put(LogActivator.IMAGE_KEY, LogActivator.getImageDescriptor("resources/logitem.png"));
	}
}
